
import 'package:elephant_fish/page/launch_page.dart';
import 'package:elephant_fish/page/login_page.dart';
import 'package:elephant_fish/tencentImPlugin/custom_animation.dart';
import 'package:elephant_fish/tencentImPlugin/provider/conversion.dart';
import 'package:elephant_fish/tencentImPlugin/provider/currentMessageList.dart';
import 'package:elephant_fish/tencentImPlugin/provider/friend.dart';
import 'package:elephant_fish/tencentImPlugin/provider/friendApplication.dart';
import 'package:elephant_fish/tencentImPlugin/provider/groupApplication.dart';
import 'package:elephant_fish/tencentImPlugin/provider/keybooadshow.dart';
import 'package:elephant_fish/tencentImPlugin/provider/user.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import './routes/routes.dart' as router;
import 'http/core/hi_net.dart';
import 'http/request/base_request.dart';
import 'http/request/home_cover_request.dart';
import 'model/app_cover_entity.dart';

void main() {
  // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后，是为了在渲染后进行set赋值，覆盖状态栏，写在渲染之前       MaterialApp组件会覆盖掉这个值。
  SystemUiOverlayStyle systemUiOverlayStyle =
  SystemUiOverlayStyle(statusBarColor: Colors.transparent);
  SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  runApp(MyApp());
  configLoading();
}

void configLoading() {
  EasyLoading.instance
    ..displayDuration = const Duration(milliseconds: 2000)
    ..indicatorType = EasyLoadingIndicatorType.fadingCircle
    ..loadingStyle = EasyLoadingStyle.dark
    ..indicatorSize = 45.0
    ..radius = 10.0
    ..progressColor = Colors.yellow
    ..backgroundColor = Colors.green
    ..indicatorColor = Colors.yellow
    ..textColor = Colors.yellow
    ..maskColor = Colors.blue.withOpacity(0.5)
    ..userInteractions = true
    ..dismissOnTap = false
    ..customAnimation = CustomAnimation();
}

class MyApp extends StatefulWidget {
  final List<AppCoverEntity> appCoverEntities;
  const MyApp({Key key, this.appCoverEntities}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {


  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
        providers: [
          ChangeNotifierProvider(create: (_) => ConversionModel()),
          ChangeNotifierProvider(create: (_) => UserModel()),
          ChangeNotifierProvider(create: (_) => CurrentMessageListModel()),
          ChangeNotifierProvider(create: (_) => FriendListModel()),
          ChangeNotifierProvider(create: (_) => FriendApplicationModel()),
          ChangeNotifierProvider(create: (_) => GroupApplicationModel()),
          ChangeNotifierProvider(create: (_) => KeyBoradModel()),
        ],
        child: MaterialApp(
            title: '象鱼',
            theme: ThemeData(
              primarySwatch: Colors.blue,
              visualDensity: VisualDensity.adaptivePlatformDensity,
              platform: TargetPlatform.iOS,
            ),
            builder: EasyLoading.init(),
            initialRoute: router.initialRoute,
            routes: router.routes,
            home: LaunchPage()));
  }

}
